package com.kanshu.ksgb.fastread.doudou.module.personal.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.widget.TextView;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;
import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.module.personal.bean.EncashRecordInfo;

import java.text.DecimalFormat;
import java.util.List;

public class EncashRecordAdapter extends BaseQuickAdapter<EncashRecordInfo> {

    public EncashRecordAdapter(Context context, List<EncashRecordInfo> data) {
        super(context, data);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_encash_record_layout;
    }

    @Override
    protected void convert(BaseViewHolder holder, EncashRecordInfo item, int position) {
        //提现状态；0：申请提现；1：提现进行中；2：提现成功；3：提现失败；-1：审核不通过
        String statusStr;
        int statusColor = Color.parseColor("#878787");
        String preStr = "";
        if ("0".equals(item.getStatus()) || "1".equals(item.getStatus())) {
            //正在提现
            statusColor = Color.parseColor("#FC4133");
            statusStr = "正在提现中";
        } else if ("2".equals(item.getStatus())) {
            //提现成功
            statusStr = "";
            preStr = "+ ";
        } else if ("-1".equals(item.getStatus())) {
            statusStr = "(审核未通过)";
        } else {
            statusStr = "(" + item.error_message + ")";
        }
        holder.setText(R.id.tvContent, item.getType_title());
        holder.setText(R.id.tvStatus, statusStr);
        ((TextView) holder.getView(R.id.tvStatus)).setTextColor(statusColor);
        if (!TextUtils.isEmpty(item.getExamine_time()) && item.getExamine_time().length() > 3) {
            holder.setText(R.id.tvDate, item.getExamine_time().substring(0, item.getExamine_time().length() - 3));
        }
        int rmbF = Integer.parseInt(item.getRmb());
        holder.setText(R.id.tvAmount, preStr + new DecimalFormat("0.00").format(rmbF / 100f));
    }

}
